home *** CD-ROM | disk | FTP | other *** search
/ Final Fantasy the Spirits Within Cardz / Final Fantasy the Spirits Within CD Cardz - Disc 3: Dr. Sid.iso / pc / assets / sid-vehicles&gear.dcr / 00012_button movement behavior.ls < prev    next >
Encoding:
Text File  |  2001-07-22  |  1.0 KB  |  51 lines

  1. property my, x, IncrementValue, XIncrement, RandomCounter, counter
  2.  
  3. on beginSprite me
  4.   Initialize(me)
  5. end
  6.  
  7. on exitFrame me
  8.   update(me)
  9. end
  10.  
  11. on Initialize me
  12.   my = me.spriteNum
  13.   sprite(my).locH = random(800)
  14.   sprite(my).blend = 0
  15.   RandomCounter = random(900)
  16.   counter = 1
  17.   IncrementValue = random(4)
  18.   RandomX = random(2)
  19.   if RandomX = 1 then
  20.     XSign = 1
  21.   else
  22.     XSign = -1
  23.   end if
  24.   XIncrement = IncrementValue * XSign
  25.   x = sprite(my).locH
  26. end
  27.  
  28. on update me
  29.   if sprite(my).blend < 30 then
  30.     sprite(my).blend = sprite(my).blend + 1
  31.   end if
  32.   if counter < RandomCounter then
  33.     if (sprite(my).locH > -50) and (sprite(my).locH < 850) then
  34.       x = x + XIncrement
  35.       sprite(my).locH = x
  36.       counter = counter + 1
  37.     else
  38.       if (sprite(my).locH <= -50) or (sprite(my).locH >= 850) then
  39.         XIncrement = -XIncrement
  40.         x = x + XIncrement
  41.         sprite(my).locH = x
  42.       end if
  43.     end if
  44.   else
  45.     if counter = RandomCounter then
  46.       RandomCounter = random(900)
  47.       counter = 1
  48.     end if
  49.   end if
  50. end
  51.